<?php
	$url_prefix = "/SMS/";

	// Database initialisation...
	$db = mysql_connect("localhost:/tmp/mysql.sock","root","");
	mysql_select_db("sms",$db);

	global $settings;
	loadsettings();

	function loadsettings(){
		global $settings;
		$sql = mysql_query("SELECT * FROM smssettings");
		while($row = mysql_fetch_array($sql, MYSQL_ASSOC)){
			$settings[$row["settingName"]] = $row["settingValue"];
		}
	}

	function htmlmenu($page = "sms"){
		global $url_prefix;
		echo '
		<div id="header">
			<ul id="nav1" class="lavaLampBottomStyle">
				<li'.(($page=="sms")?' class="current"':'').'><a href="'.$url_prefix.'sms/">SMS</a></li>
				<li'.(($page=="texts")?' class="current"':'').'><a href="'.$url_prefix.'texts/">Texts</a></li>
				<li'.(($page=="commands")?' class="current"':'').'><a href="'.$url_prefix.'commands/">Commands</a></li>
				<li'.(($page=="settings")?' class="current"':'').'><a href="'.$url_prefix.'settings/">Settings</a></li>
				<li'.(($page=="about")?' class="current"':'').'><a href="'.$url_prefix.'about/">About</a></li>
			</ul>
		</div>
		';
	}


	function htmlheader($script = ''){
		global $url_prefix;
		echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
		   "http://www.w3.org/TR/html4/strict.dtd">
		<html lang="en">
		<head>
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
			<link rel="shortcut icon" type="image/x-icon" href="'.$url_prefix.'favicon.ico" />
			<title>SMS</title>
			<meta name="author" content="Thomas De Groote">
			<link rel="stylesheet" href="'.$url_prefix.'main.css" type="text/css" media="all" title="Main Stylesheet" charset="utf-8">
			<link rel="stylesheet" href="'.$url_prefix.'scripts/jScrollPane.css" type="text/css" media="all" charset="utf-8">
			<link rel="stylesheet" href="'.$url_prefix.'scripts/date_input.css" type="text/css" media="all" charset="utf-8">
			<script type="text/javascript" src="'.$url_prefix.'scripts/jquery-1.2.6.min.js"></script>
			<script type="text/javascript" src="'.$url_prefix.'scripts/jquery.dimensions.min.js"></script>
			<script type="text/javascript" src="'.$url_prefix.'scripts/jquery.mousewheel.min.js"></script>
			<script type="text/javascript" src="'.$url_prefix.'scripts/jquery.easing.min.js"></script>
			<script type="text/javascript" src="'.$url_prefix.'scripts/jquery.lavalamp.min.js"></script>
			<script type="text/javascript" src="'.$url_prefix.'scripts/jquery.date_input.js"></script>
			<script type="text/javascript" src="'.$url_prefix.'scripts/jScrollPane.js"></script>
			<script type="text/javascript" src="'.$url_prefix.'scripts/common.js"></script>
			<script type="text/javascript">
			$(document).ready(function() {
		//		stripetables();

				$(".smslist tr").hover(
					function(){$(this).addClass("stripelight");}, 
					function(){$(this).removeClass("stripelight");}
				);
				
				$(":text").focus(function(){ $(this).addClass("activeinput"); });
				$(":text").blur(function(){ $(this).removeClass("activeinput"); });

			    $(".lavaLampBottomStyle").lavaLamp({ fx: "backout", speed: 700 });

			});
			'.
			$script
			.'
			</script>

		</head>
		<body>
		';
		htmlmenu($_GET["m"]);
		echo '
			<div id="mainbox">
		';
	}

	function htmlfooter(){
		echo '
			</div>
		</body>
		</html>
		';
	}
?>